package com.pgcomb.poweriot.alarmservice.alarm.service;

import com.pgcomb.common.bean.AlarmData;
import com.pgcomb.common.enums.AlarmType;
import com.pgcomb.poweriot.alarmservice.alarm.AlarmMessageFactory;
import com.pgcomb.poweriot.alarmservice.alarm.CommonAlarmMessage;
import com.pgcomb.web.dao.Equipment;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

/**
 * @author zhengheqi
 * @version 1.0
 * @description: 设备 在线、离线 状态异常警告信息
 * @date 2021/5/29 16:22
 */
@Component
public class StatusAlarmMessage extends CommonAlarmMessage implements InitializingBean {

    @Override
    protected String getAlarmMessage(AlarmData alarmData) throws Exception {
        String sbId = alarmData.getSbId();
        Equipment equipment = getEquipment(sbId);
        if(ObjectUtils.isEmpty(equipment)){
            throw new Exception("error");
        }

        //TODO 组装告警信息


        return "test";
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        AlarmMessageFactory.register(AlarmType.STATUS_ALARM, this);
    }
}
